/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package manager;

import entity.Department;
import iface.IManager;
import java.util.ArrayList;

/**
 *
 * @author User
 */
public class DepartmentManager implements IManager<Department> {

    private Manager manager;
    private ArrayList<Department> departmentList;

    public DepartmentManager(Manager manager) {
        departmentList = new ArrayList<Department>();
        this.manager = manager;
    }

    @Override
    public void add(Department obj) {
        this.departmentList.add(obj);
    }

    @Override
    public void remove(Department obj) {
        this.departmentList.remove(obj);
        obj.setStatus(false);
        this.manager.getDisabledDepartmentManager().add(obj);
    }

    @Override
    public Department replace(int index, Department obj) {
        return this.departmentList.set(index, obj);
    }

    @Override
    public int size() {
        return this.departmentList.size();
    }

    @Override
    public Department get(int index) {
        return this.departmentList.get(index);
    }

    public Department getByID(int departmentID) {
        for(Department department: this.departmentList) {
            if(department.getDepartmentID() == departmentID)
                return department;
        }
        return null;
    }
}
